var loadPath = $("#loadPath").val();
function loadList(){
	$('#menu_tbody').empty();
	$.ajax({
		url:loadPath+"/menu/list",
		type:"post",
		dataType:"json",
		success : function(json){
			$("#Menu_Modular").tmpl(json.resultList).appendTo('#menu_tbody');
		}
	});
}
$(function(){
	loadList();
	
	$("#add_menu_btn").click(function(){
		$("#responsive").removeClass("hide");
		layer.open({
			  type: 1,
			  title:"添加菜单",
			  closeBtn:0,
			  area: ['450px', '350px'],
			  shadeClose: false, //点击遮罩关闭
			  content: $("#responsive"),
			  btn: ['保存', '取消'],
			  btn1: function(index, layero){
				  var data = $("#menu_form").serializeArray();
				   $.ajax({
					   url:loadPath+"/menu/add",
					   data:data,
					   type:"post",
					   dataType:"json",
					   success : function(json){
						   if(json.success){
							   layer.alert('新增成功');
							   loadList(); 
						   }else{
							   layer.alert('新增失败');
						   }
						   layer.close(index);
						   $("#responsive").addClass("hide");
					   }
				   });
			  },
			  btn2:function(index,layero){
				  $("#responsive").addClass("hide");
			  }
			 });
	});
	
	$("#delete_menu_btn").click(function(){
		
	});
});
